

#include <errno.h>
#include <stdio.h>
#include <string.h>

#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>

#include "config.h"

int main( void )
{
	int clientSocket;
	int socketAddr_len;
	struct sockaddr_un socketAddr;
	
	clientSocket = socket( PF_UNIX, SOCK_STREAM, 0 );
	if( clientSocket < 0 )
	{
		printf( "Cannot create a UNIX socket to listen on!\n" );
		return 1;
	}
	
	socketAddr.sun_family = AF_UNIX;
	strcpy( socketAddr.sun_path, SOCKET_PATH );
	
	socketAddr_len = strlen( socketAddr.sun_path ) + 1 + sizeof( socketAddr.sun_family );
	
	if( connect(clientSocket, (struct sockaddr *) &socketAddr, socketAddr_len ) < 0 )
	{
		printf( "Cannot connect to socket (%i)\n", errno );
		return 1;
	}
	
	send( clientSocket, "Hello World", sizeof( "Hello World") + 1, 0 );
	
	return 0;
}

